package com.express.sys.service.impl;

import com.express.entity.Role;
import com.express.entity.RolePermission;
import com.express.sys.mapper.RoleMapper;
import com.express.sys.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 角色Service实现类
 *
 * @author zhouling
 * @since 2018年6月10日 下午4:16:33
 */
@Service
public class RoleServiceImpl implements RoleService {

	@Autowired
	RoleMapper roleMapper;

	@Override
	public Role getById(Integer id) {
		return this.roleMapper.selectByPrimaryKey(id);
	}
	@Override
	public List<Role> getList() {
		return this.roleMapper.selectPage();
	}
	@Override
	public void add(Role role) {
		this.roleMapper.insertSelective(role);
	}
	@Override
	public void update(Role role) {
		this.roleMapper.updateByPrimaryKeySelective(role);
	}
	@Override
	public void delete(int[] ids) {
		this.roleMapper.deleteByPrimaryKey(ids);
	}
	@Override
	public boolean checkCode(Role role) {
		List<Role> list = this.roleMapper.checkCode(role);
		if ((list != null) && (list.size() > 0)) {
			return true;
		}
		return false;
	}
	@Override
	public List<RolePermission> getRPermission(Integer roleId) {
		return this.roleMapper.getRPermission(roleId);
	}
	@Override
	public void delRPermission(Integer roleId) {
		this.roleMapper.delRPermission(roleId);
	}
	@Override
	public void setRPermission(RolePermission rolePermission) {
		this.roleMapper.setRPermission(rolePermission);
	}
	@Override
	public List<Map<String, Object>> getRolePermission(Integer roleId) {
		return this.roleMapper.getRolePermission(roleId);
	}
}
